package com.djl.spring.redis.util;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.stereotype.Component;

import java.util.*;

@Component
public class RedisUtil {

    @Autowired
    RedisTemplate redisTemplate;

    @Autowired
    MessageListenerAdapter messageListenerAdapter;
    /**
     * 发布消息
     */
    public void sendMessage(){
        //发布消息
        redisTemplate.convertAndSend("ooxx","oneTwo");
        System.out.println("已发送成功!");
    }

}
